package com.qianqu.module_home.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.qianqu.lib_base.utils.FragmentUtils;
import com.qianqu.module_home.R;
import com.qianqu.module_home.adapter.MainAdapter;

import java.util.ArrayList;

/**
 * ${description}
 *
 * @author weiqiliu
 * @version 1.0 2018/6/25
 */
public class MainActivity extends AppCompatActivity {
    private ViewPager viewPager;
    private MainAdapter mainAdapter;
    private ArrayList<Fragment> fragmentList = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initData();
        setViewPagerAdapter();
    }

    private void initView() {
        viewPager = (ViewPager) findViewById(R.id.viewPager);
    }

    private void initData() {
        fragmentList.clear();
        fragmentList.add(FragmentUtils.getHomeFragment());
    }

    private void setViewPagerAdapter() {
        mainAdapter = new MainAdapter(getSupportFragmentManager(), fragmentList);
        viewPager.setAdapter(mainAdapter);
    }
}
